{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import numpy as np\n",
    "from natsort import natsorted\n",
    "import cv2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "path = './PINN/Burgers Equation/solution_evolution/data/pic'\n",
    "video_name = './PINN/Burgers Equation/solution_evolution/solution_evolution.mkv'\n",
    "path = 'home/A'\n",
    "video_name = 'home/A/solution_evolution.mkv'\n",
    "files = os.listdir(path)\n",
    "\n",
    "all_images = [img for img in natsorted(files)] #list of all files in correct sequence\n",
    "\n",
    "#we take every nth\n",
    "n = 5\n",
    "images = [all_images[i] for i in np.arange(int(len(all_images)/n))*n]\n",
    "\n",
    "frame = cv2.imread(os.path.join(path, images[0]))\n",
    "height, width, layers = frame.shape\n",
    "\n",
    "video = cv2.VideoWriter(video_name, 0, 10, (width,height))\n",
    "\n",
    "for image in images:\n",
    "    video.write(cv2.imread(os.path.join(path, image)))\n",
    "\n",
    "cv2.destroyAllWindows()\n",
    "video.release()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
